<template>
<el-sub-menu v-if="hasChildren" :index="props.index">
    <template #title>
      {{ props.item.label }}
    </template>

    <menu-item
      v-for="(child, childIndex) in props.item.children"
      :key="childIndex"
      :item="child"
      :index="props.item.menu_url"
    />
  </el-sub-menu>

  <el-menu-item v-else :index="props.item.menu_url">
    {{ props.item.label }}
  </el-menu-item>
</template>
<script lang="ts" setup>
const props = defineProps({
  item: {
    type: Object,
    default: {},
  },
  index: {
    type: String,
    required: true,
  },
});

const hasChildren = props.item.children && props.item.children.length > 0;
</script>
  <style lang="scss" scoped></style>